import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 暗言术-痛
 **/
export default class MS_InsinuationPain extends AbilityBase {
    static instance: MS_InsinuationPain;
    buffType: AppBuffType = {
        id: 'buff_MS_InsinuationPain',
        name: this.abilityName,
        art: this.art,
        ubertip: '持续受到暗系伤害',
        interval: 1,
        onInterval: this.onBuffInterval.bind(this),
        dur: 12,
    };
    onBuffInterval(buff: Buff) {
        let lv = this.getAbilityLevel(buff.getCaster());
        let dmg = 14 * lv + UnitCommon.取法强(buff.getCaster()) * (0.7 + 0.3 * lv);
        DamageSystemInstance.applyDarkDamage(buff.getParent(), buff.getCaster(), dmg, this.id, true);
        DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl', buff.getParent(), 'chest'));
    }
    constructor(id: string) {
        super(id);
        MS_InsinuationPain.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BuffCommon.addBuff({
            target,
            caster: source,
            buffTypeId: this.buffType.id,
            ablityId: this.id,
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
